﻿using Brc_PaaS.Bll.Apollo;
using Brc_PaaS.Common.Model.Apollo;
using Brc_PaaS.Common.Model.Basic;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;

namespace Brc_PaaS.Api.PaaSController
{
    [Route("PaaS/[controller]/[action]")]
    [ApiController]
    [EnableCors("any")]
    [ApiExplorerSettings(GroupName = "PaaSBasic")]
    public class PaaSConfigController : ControllerBase
    {
        private readonly IApollo apolloService;
        private readonly IConfiguration configuration;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="apolloService"></param>
        public PaaSConfigController(IApollo apolloService,IConfiguration configuration)
        {
            this.apolloService = apolloService;
            this.configuration = configuration;
        }


        /// <summary>
        /// 创建匿名空间
        /// </summary>
        /// <param name="createNamespaceViewDto"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult<ResponseModel<string>> CreateNamespace([FromBody]CreateNamespaceViewDto createNamespaceViewDto)
        {
            
            var result = apolloService.CreateNamespace(createNamespaceViewDto);
            return Ok(result);
        }
        /// <summary>
        /// 保存配置信息
        /// </summary>
        /// <param name="createConfigViewDto"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult<BaseResponseModel> SaveConfig([FromBody]CreateConfigViewDto createConfigViewDto)
        {
            var result = apolloService.SaveConfig(createConfigViewDto);
            return Ok(result);

        }
        /// <summary>
        /// 删除配置
        /// </summary>
        /// <param name="deleteConfigViewDto"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult<BaseResponseModel> DeleteConfig([FromBody]DeleteConfigViewDto deleteConfigViewDto)
        {
            var result = apolloService.DeleteConfig(deleteConfigViewDto);
            return Ok(result);

        }
  
    }
}